package chapter3;

import chapter2.Vehicle;

public class Garage implements Cloneable {
    
    private String name;
    private Vehicle[] vs;
    
    public Garage(int max){
        vs = new Vehicle[max];
    }
    
    public Garage clone(){
        try{
            Garage nObj = (Garage)super.clone();
            //clone array
            nObj.vs = vs.clone();
            //clone each elements in array that not primitive type
            for(int i=0;i<nObj.vs.length;i++){
                nObj.vs[i] = vs[i].clone();
            }
            return nObj;
        }catch(CloneNotSupportedException e){
            return null;
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

    }

}
